namespace HCMUTE_analysic.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class lan2 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Users",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Username = c.String(),
                        Password = c.String(),
                        Email = c.String(),
                        Fullname = c.String(),
                        DateCreate = c.DateTime(nullable: false),
                        DateUpdate = c.DateTime(nullable: false),
                        UserLevelID = c.Int(nullable: false),
                        UserAttemptID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.UserLevels", t => t.UserLevelID, cascadeDelete: true)
                .Index(t => t.UserLevelID);
            
            CreateTable(
                "dbo.UserLevels",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Permissions",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        KeyValue = c.String(),
                        UserLevelID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.UserLevels", t => t.UserLevelID, cascadeDelete: true)
                .Index(t => t.UserLevelID);
            
            CreateTable(
                "dbo.UserAttempts",
                c => new
                    {
                        ID = c.Int(nullable: false),
                        TimeLogin = c.Int(nullable: false),
                        TimeLoginAfter = c.DateTime(nullable: false),
                        UserID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Users", t => t.ID)
                .Index(t => t.ID);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.UserAttempts", new[] { "ID" });
            DropIndex("dbo.Permissions", new[] { "UserLevelID" });
            DropIndex("dbo.Users", new[] { "UserLevelID" });
            DropForeignKey("dbo.UserAttempts", "ID", "dbo.Users");
            DropForeignKey("dbo.Permissions", "UserLevelID", "dbo.UserLevels");
            DropForeignKey("dbo.Users", "UserLevelID", "dbo.UserLevels");
            DropTable("dbo.UserAttempts");
            DropTable("dbo.Permissions");
            DropTable("dbo.UserLevels");
            DropTable("dbo.Users");
        }
    }
}
